class MakeDir extends JSCommand {
	
	private static final String cmdName = "mkdir";
	private static final String dirFullError = "Error: Directory %s is full. Directory %s not added.";
	private static final String FILE_EXISTS = "%s: File exists";
	
	public String runCommand(String[] commandArgs, JShell shell) {

		String result = new String();
		JSDirectory workDir = shell.getWorkDir();
		boolean validArgs = isValidArgs(commandArgs, shell);
		
		if (validArgs) {
			
			String newDirName;
			int i;
			for (i = 1; i < commandArgs.length; i++) {
			
				newDirName = commandArgs[i];
			
				// Check if there is room for a new folder
				if (workDir.isFull()) {
					result = String.format(dirFullError, workDir.getAddress(), newDirName);
				} else if (workDir.hasFile(newDirName)) {
					result = String.format(FILE_EXISTS, newDirName);
				} else {
					// Create the new directory according to cmdArgs
					JSDirectory newDir = new Directory(newDirName, workDir);
					workDir.addDirectory(newDir);
				}
			
			}
		
		} else {
			result = invalidArgsMessage;
		}
		
		return result;
	}
	
	private boolean isValidArgs(String[] cmdArgs, JShell shell) {
		return (true);
	}
}
